from django.db import models
from mongoengine import *

# connect('ordering', host='127.0.0.1', port=27017) # 指明要连接的数据库
# Create your models here.


class MenuFood(EmbeddedDocument):
    id = IntField()
    name = StringField()
    price = FloatField()
    remarks = StringField()
    image = StringField()
    status = StringField()


class CookBook(Document):
    menu_id = ObjectIdField()
    period_number = StringField()
    status = StringField()
    banner = StringField()
    community_id = ObjectIdField()
    order_time = StringField()
    delivery_time = StringField()
    hot_push = StringField()
    menu = ListField(EmbeddedDocumentField(MenuFood))

    meta = {'collection': 'cookbook'}   # 指明连接数据库的哪张表


# for i in CookBook.objects[:1]:  # 测试是否连接成功
#     print(i.period_number)
# food = MenuFood(name ="name2",price=1.11,remarks="备注",image="image_url")
#
# cookBook = CookBook(status="状态", cookbook="图片路径",period_number="第2期",community_id="1", order_time="ordertime",delivery_time ="deliverytime",hot_push="热推",menu=[food])
# cookBook.save()

# class user(Document):
#     title = StringField()
#     url = StringField()
#     price = StringField()
#     pub_date = StringField()
#     look = StringField()
#     area = ListField(StringField()) # 定义列表类型
#     cates = ListField(StringField())
#
#     meta = { 'collection': 'user'} # 指明连接数据库的哪张表





